/*
 * @Description: 动态创建数组
 * @Version: 1.0
 * @Author: marshal
 * @Date: 2022-06-21 20:37:53
 * @LastEditors: marshal
 * @LastEditTime: 2023-09-07 08:55:00
 */
#include <stdio.h>
#include <stdlib.h>
#define SIZE 10

/**
 * print array
*/
void printArray(int * arr, int size);

int main(int argc, char const *argv[])
{
    // Allocate memory
    int* nums = malloc(SIZE * sizeof(int));
    for (int i = 0; i < SIZE; i++) {
        *(nums + i) = i * i;
    }

    // print
    printArray(nums, SIZE);
    // free memory
    free(nums);
    return 0;
}

void printArray(int * arr, int size) {
    for (int i = 0; i < size; i++) {
        printf("%d\n", *(arr + i));
    }
}
